package card

import (
	"server/game/bag"
)

func EnCardNengLi(userId string) float64 {
	logic := NewCardLogic()
	return logic.cardNengLi(userId)
}

func EnAddCard(userId string, ctid int64) (map[string]interface{}, error) {
	logic := NewCardLogic()
	_, err := logic.cardInfoByUserIdAndCtId(userId, ctid)
	ret := make(map[string]interface{}, 0)
	if err != nil {
		card, err := logic.newCard(userId, ctid)
		if err != nil {
			return ret, err
		}
		bagList, err := bag.EnGetUserItem(userId)
		ret["care_list"] = card
		ret["bag_list"] = bagList
	}
	item, err := bag.EnAddItem(userId, 150002, 1)
	if err != nil {
		return ret, err
	}
	card, _ := logic.cardListByUserId(userId)
	ret["care_list"] = card
	ret["bag_list"] = item
	return ret, nil
}

func EnGetUserAllCardNengLi(userId string) float32 {
	return GetUserAllCardNengLi(userId)
}
func EnGetUserCardInfoByCardId(userId string, cardId string) (CardInfo, error) {
	logic := NewCardLogic()
	return logic.cardInfoByUserIdAndCardId(userId, cardId)
}
func EnGetUserCardInfoByCardTId(userId string, cardId int64) (CardInfo, error) {
	logic := NewCardLogic()
	return logic.cardInfoByUserIdAndCtId(userId, cardId)
}
func EnGetUserCardListByUid(userId string) []CardInfo {
	logic := NewCardLogic()
	ret, err := logic.cardListByUserId(userId)
	if err != nil {
		return nil
	}
	return ret
}
